package com.nbsaas.boot.customer.rest.convert;

import com.nbsaas.boot.entity.customer.MemberProfile;
import com.nbsaas.boot.customer.api.domain.simple.MemberProfileSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* 会员-列表对象转换器
*/

public class MemberProfileSimpleConvert implements Converter<MemberProfileSimple, MemberProfile> {




@Override
public MemberProfileSimple convert(MemberProfile source) {
    MemberProfileSimple result = new MemberProfileSimple();

                result.setIncome(source.getIncome());

               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }

                result.setEducation(source.getEducation());
                result.setGender(source.getGender());
                if(source.getHasChildren()!=null){
                   Map<Integer,String> HasChildrenMap=new HashMap<>();
                       HasChildrenMap.put(1,"有");
                       HasChildrenMap.put(0,"无");
                   String label=  HasChildrenMap.get(source.getHasChildren());
                   result.setHasChildrenName(label);
                }
                result.setHasChildren(source.getHasChildren());
                result.setPhoto(source.getPhoto());
                result.setWeight(source.getWeight());
                result.setAddDate(source.getAddDate());
                result.setWorkLocation(source.getWorkLocation());
                result.setBirthYear(source.getBirthYear());
                result.setPhone(source.getPhone());
                result.setPartnerRequirements(source.getPartnerRequirements());
                result.setName(source.getName());
                if(source.getHasHouse()!=null){
                   Map<Integer,String> HasHouseMap=new HashMap<>();
                       HasHouseMap.put(1,"有");
                       HasHouseMap.put(0,"无");
                   String label=  HasHouseMap.get(source.getHasHouse());
                   result.setHasHouseName(label);
                }
                result.setHasHouse(source.getHasHouse());
                if(source.getStoreState()!=null){
                    result.setStoreStateName(String.valueOf(source.getStoreState()));
                }
                result.setStoreState(source.getStoreState());
                result.setId(source.getId());
                result.setJob(source.getJob());
                result.setMaritalStatus(source.getMaritalStatus());
                if(source.getHasCar()!=null){
                   Map<Integer,String> HasCarMap=new HashMap<>();
                       HasCarMap.put(1,"有");
                       HasCarMap.put(0,"无");
                   String label=  HasCarMap.get(source.getHasCar());
                   result.setHasCarName(label);
                }
                result.setHasCar(source.getHasCar());
                result.setHeight(source.getHeight());
                result.setFamilyStatus(source.getFamilyStatus());
                result.setLastDate(source.getLastDate());


    return result;
}

}